<template>
	<view class="user-info">
		<view class="user-icon u-f u-f-jsb">
			<!-- 第三方登录要用，但是我没申请来。。唉 暂时先空着 -->
			<!-- <block v-for="(value,key) in providerList" @click="tologin(value)"
                    :key="key">
				<u-icon :name="value.name" :color="value.color" size="100"></u-icon>
				
			</block> -->	
			<u-icon name="weixin-circle-fill" color="  #2AD19B" size="100"></u-icon>
			<u-icon name="weibo-circle-fill" color="  #EE5E5E" size="100"></u-icon>
			<u-icon name="qq-circle-fill" color="#5280CE" size="100"></u-icon>	 
		</view>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				 providerList: []
			}
		},
		methods:{
			tologin(provider) {
			    uni.login({
			        provider: provider.id,
			        // #ifdef MP-ALIPAY
			        scopes: 'auth_user', //支付宝小程序需设置授权类型
			        // #endif
			        success: (res) => {
			            console.log('login success:', res);
			            // 更新保存在 store 中的登录状态
			            this.login(provider.id);
			        },
			        fail: (err) => {
			            console.log('login fail:', err);
			        }
			    });
			}
		},
		//获取初始化信息
		mounted() {
			
		    uni.getProvider({
		        service: 'oauth',
		        success: (result) => {
					
		            this.providerList = result.provider.map((value) => {
		                let providerName = '';
		                switch (value) {
		                    case 'weixin':
		                        providerName = 'weixin-circle-fill',
								color='#2AD19B'
		                        break;
		                    case 'qq':
		                        providerName = 'qq-circle-fill',
								color='#5280CE'
								
		                        break;
		                    case 'sinaweibo':
		                        providerName = 'weibo-circle-fill',
								color='#5280CE'
		                        break;
		                    
		                }
						console.log(value)
		                return {
		                    name: providerName,
		                    id: value,
							color:color
		                }
		            });
		
		        },
		        fail: (error) => {
		            console.log('获取登录通道失败', error);
		        }
		    });
		},
	}
</script>

<style>
	.user-icon{
		
		margin: 30upx 150upx;
	}
</style>
